package ebj.common.reflection;

import ebj.common.domain.Person;
import ebj.common.utils.Utils;


/**
 * 反射实例2：通过Class实例化其他类的对象
 * @author zhouxiangyong
 * @version $Id$
 */
public class ReflectClient2 {

	public static void main(String[] args) {
		String clazzName = Utils.getProperty("Person");
		Class<?> clazz = null;
		Person person = null;
		try {
			clazz = Class.forName(clazzName);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		try {
			person = (Person) clazz.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		
		person.setName("张三");
		person.setAge(26);
		System.out.println(person);
	}
}
